<%@ page import="java.sql.*" %>
<%@ page import = "student.StudentsClass" %>
<jsp:useBean id="student" class="student.StudentsClass" scope="session"/>
<jsp:setProperty name="student" property="*"/>
<html>
<head>
<title>Students Database</title>
</head>
<body bgcolor="#CCCCFF">

<a href="AddItem.jsp">Add Record</a>&nbsp;&nbsp;
<a href="StudentDatabase.jsp">Refresh</a>

<!--
<form>
<input type="button" action="AddItem.jsp" value="Add" />
<input type="button" action="StudentDatabase.jsp" value="Refresh" />
</form>
-->

<h3>Students</h3>
<table border="1">
<tr>
	<td><b>Name</b></td>
	<td><b>Location</b></td>
	<td><b>Phone number</b></td>
</tr>
<%
	Connection con = null;
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	con = DriverManager.getConnection("jdbc:odbc:jdbctest", "user", "user");
    Statement stmt = con.createStatement();
	stmt.executeQuery("select * from student");
	ResultSet rs = stmt.getResultSet();
	String tempName= "";
	while(rs.next()) {
	tempName=rs.getString(1);
	out.println("<tr><td>" + tempName + "</td>");
	out.println("<td>" + rs.getString(2) + "</td>");
	out.println("<td>" + rs.getString(3) + "</td>");
	out.println("<td><form method=\"POST\"><input type=\"hidden\" value=\"" + tempName + "\" name=\"update\" />");
	out.println("<input type=\"submit\" value=\"Update\" /></form></td>");
	out.println("<td><form method=\"POST\"><input type=\"hidden\" value=\"" + tempName + "\" name=\"delete\" />");
	out.println("<input type=\"submit\" value=\"Delete\" /></form></td></tr>");
	} 
%>
</table>
</body>
</html>